﻿using Sw.Hospital.HealthExaminationSystem.ApiProxy.CusReg;
using Sw.Hospital.HealthExaminationSystem.Application.Common;
using Sw.Hospital.HealthExaminationSystem.Application.CusReg.Dto;
using Sw.Hospital.HealthExaminationSystem.Common.Bases;
using Sw.Hospital.HealthExaminationSystem.Common.Enums;
using Sw.Hospital.HealthExaminationSystem.Common.UserCache;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Sw.Hospital.HealthExaminationSystem.Statistics.CusRegStatis
{
    public partial class frmTJLJ : UserBaseForm
    { private CustomerAppService customerApp = new CustomerAppService();
        private readonly ICommonAppService _commonAppService;
        public frmTJLJ()
        {
            _commonAppService = new CommonAppService();
            InitializeComponent();
        }

        private void frmTJLJ_Load(object sender, EventArgs e)
        {
            repositoryItemLookUpEditPhysicalType.DataSource = DefinedCacheHelper.GetBasicDictionary().Where(o => o.Type == BasicDictionaryType.ExaminationType.ToString())?.ToList();
            repositoryItemLookUpEdit1.DataSource = DefinedCacheHelper.GetComboUsers();
            dateEdit1.EditValue = _commonAppService.GetDateTimeNow().Now.ToShortDateString();
            dateEdit2.EditValue= _commonAppService.GetDateTimeNow().Now.ToShortDateString();

        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            SearchDto search = new SearchDto();
            if (!string.IsNullOrEmpty(dateEdit1.EditValue?.ToString()) && !string.IsNullOrEmpty(dateEdit2.EditValue?.ToString()))
            {
                search.Star =DateTime.Parse( dateEdit1.DateTime.ToShortDateString());
                search.End = DateTime.Parse(dateEdit2.DateTime.AddDays(1).ToShortDateString());
            }
            if (!string.IsNullOrEmpty(textName.Text))
            { search.Name = textName.Text; }
            if (!string.IsNullOrEmpty(cusBM.Text))
            { search.cusRegBM = cusBM.Text; }
          var cuslist=  customerApp.ShowCus(search);
            gridControl1.DataSource = cuslist;
        }
    }
}
